package com.taotao.rest.dao.ipml;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import redis.clients.jedis.JedisCluster;

import com.taotao.rest.dao.IJedisClient;

public class JedisClientCluster implements IJedisClient {

	@Autowired
	private JedisCluster jedisCluster;

	@Override
	public String get(String key) {
		String str = null;
		try {
			str = this.jedisCluster.get(key);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return str;
	}

	@Override
	public String set(String key, String value) {
		// TODO Auto-generated method stub
		String str = null;
		try {
			str = this.jedisCluster.set(key, value);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return str;
	}

	@Override
	public String hget(String hkey, String key) {
		// TODO Auto-generated method stub
		String str = null;
		try {
			str = this.jedisCluster.hget(hkey, key);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return str;
	}

	@Override
	public long hset(String hkey, String key, String value) {
		// TODO Auto-generated method stub
		Long l = null;
		try {
			l = this.jedisCluster.hset(hkey, key, value);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return l;
	}

	@Override
	public long incr(String key) {
		Long l = null;
		// TODO Auto-generated method stub
		try {
			l = this.jedisCluster.incr(key);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return l;
	}

	@Override
	public long expire(String key, int second) {
		// TODO Auto-generated method stub
		Long l = null;
		try {
			l = this.jedisCluster.expire(key, second);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return l;
	}

	@Override
	public long ttl(String key) {
		// TODO Auto-generated method stub
		Long l = null;
		try {
			l = this.jedisCluster.ttl(key);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return l;
	}

	@Override
	public long hdel(String hkey, String key) {
		Long l = null;
		try {
			l = this.jedisCluster.hdel(hkey, key);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return l;
	}
}
